#ifndef TCP_CONNECTION_H
#define TCP_CONNECTION_H
#include "socket_common.h"
#include <string>


namespace eGear{
class TcpConnection{
	/* use to read or write data to a socket
	 * you can read or write 
	 *
	 *
	 * */
public:
	TcpConnection(std::string _addr, int _port);
	TcpConnection(int _socket, struct sockaddr*_sockaddr,
			socklen_t _addrlen);
	~TcpConnection();
	int connect();
	std::string readLine();
	int write(std::string buf);
	int setAddr(std::string _addr) { addr = _addr; };
	int setPort(int _port) { port = _port; };
private:
	int socketfd;
	std::string addr;
	int max_addr_len;
	int port;
	struct sockaddr_in sockaddr;
};

};

#endif /* TCP_CONNECTION_H */
